package com.gitee.absolute_spirit.hiot_android.data.source.proto

import androidx.datastore.core.Serializer
import com.gitee.absolute_spirit.hiot_android.NavigateArgs
import java.io.InputStream
import java.io.OutputStream

class NavigateArgsSerializer : Serializer<NavigateArgs>{
    override val defaultValue: NavigateArgs
        get() = NavigateArgs.getDefaultInstance()

    override suspend fun readFrom(input: InputStream): NavigateArgs {
        return try {
            NavigateArgs.parseFrom(input)
        } catch (exception: Exception) {
            NavigateArgs.getDefaultInstance()
        }
    }

    override suspend fun writeTo(t: NavigateArgs, output: OutputStream) {
        t.writeTo(output)
    }
}